import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import { setupStore } from "@/store";
// import ElementPlus from "element-plus";
// 样式
import "element-plus/theme-chalk/index.css";
import zh from "element-plus/es/locale/lang/zh-cn";
import "@/styles/index.scss";
import "./permission";
import Cookies from "js-cookie";
import auth from "@/plugins/auth.ts";
// import cache from "@/plugins/cache.ts";
// import modal from "@/plugins/modal.ts";
// import download from "@/plugins/download.ts";
import rightToolbar from "@/components/RightToolbar/index.vue";
import dictDataTag from "@/components/DictDataTag/index.vue";
// 本地SVG图标
import "virtual:svg-icons-register";

// 国际化
import i18n from "@/lang/index";
// 全局注册自定义指令
import { setupDirective } from "@/directives/index";

import {
  parseTime,
  getWeek,
  handleTree,
  getNormalPath,
  resetForm,
} from "@/utils/zpPlatform";

const app = createApp(App);
app.use(router);
// 全局注册 状态管理(store)
setupStore(app);
// 全局注册 自定义指令(directive)
setupDirective(app);
// 全局注册
await router.isReady();

// app.use(ElementPlus, {
//   locale: zh,
//   size: "small",
//   zIndex: 3000,
// });
app.use(i18n);

// // 页签操作
// app.config.globalProperties.$tab = tab;
// // 认证对象
app.config.globalProperties.$auth = auth;
// // 缓存对象
// app.config.globalProperties.$cache = cache;
// // 模态框对象
// app.config.globalProperties.$modal = modal;
// // 下载文件
// app.config.globalProperties.$download = download;

// app.config.globalProperties.$baseURL = "http://localhost:9004";

// 定义全局方法
app.config.globalProperties.$parseTime = parseTime;
app.config.globalProperties.$getWeek = getWeek;
app.config.globalProperties.$handleTree = handleTree;
app.config.globalProperties.$getNormalPath = getNormalPath;
app.config.globalProperties.$resetForm = resetForm;

app.component("right-toolbar", rightToolbar);
app.component("dict-data-tag", dictDataTag);

app.mount("#app");
